/**
 * 统计报表
 */
import Vue from 'vue'
const SUCCESS = 1000000
const API_ROOT = server.root + '/newmanage'

const getBetaMonthSummaryListResource = Vue.resource(API_ROOT + '/report/betaMonthSummaryList')
export const getBetaMonthSummaryList = ({dispatch}, params) => {
  return getBetaMonthSummaryListResource.get(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return Promise.resolve(res.data)
      }
      return Promise.reject(res.data)
    })
}

const getBetaDaySummaryListResource = Vue.resource(API_ROOT + '/report/betaDaySummaryList')
export const getBetaDaySummaryList = ({dispatch}, params) => {
  return getBetaDaySummaryListResource.get(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return Promise.resolve(res.data)
      }
      return Promise.reject(res.data)
    })
}

const getTradeDataDaySummaryListResource = Vue.resource(API_ROOT + '/report/tradeDataDaySummaryList')
export const getTradeDataDaySummaryList = ({dispatch}, params) => {
  return getTradeDataDaySummaryListResource.get(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return Promise.resolve(res.data)
      }
      return Promise.reject(res.data)
    })
}

const getTradeDataSummaryByProductListResource = Vue.resource(API_ROOT + '/report/tradeDataSummaryByProductList')
export const getTradeDataSummaryByProductList = ({dispatch}, params) => {
  return getTradeDataSummaryByProductListResource.get(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return Promise.resolve(res.data)
      }
      return Promise.reject(res.data)
    })
}

const getTradeDataMonthSummaryListResource = Vue.resource(API_ROOT + '/report/tradeDataMonthSummaryList')
export const getTradeDataMonthSummaryList = ({dispatch}, params) => {
  return getTradeDataMonthSummaryListResource.get(params)
    .then((res) => {
      if (+res.data.code === SUCCESS) {
        return Promise.resolve(res.data)
      }
      return Promise.reject(res.data)
    })
}
